#include "statistic.h"
#include <QApplication>

#include<QtSql>
#include<QtGui>
#include <QCoreApplication>
#include <QSqlDatabase>
#include <QSqlQuery>
#include <QSqlTableModel>
#include <QSqlError>
#include <QDebug>


int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    QTextCodec::setCodecForTr(QTextCodec::codecForName("UTF8"));
    QTextCodec::setCodecForLocale(QTextCodec::codecForName("UTF8"));
    QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF8"));

    QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
    db.setHostName("localhost");
    db.setPort(3306);
    db.setDatabaseName("ZZB");
    db.setUserName("root");
    db.setPassword("123456");
    if(!db.open()){
        QMessageBox *msgBox = new QMessageBox(QMessageBox::Critical,QObject::tr("错误"),QObject::tr("数据库连接失败！"), QMessageBox::Abort);
        msgBox->button(QMessageBox::Abort)->setText("确定");
        msgBox->exec();
        qDebug()<<db.lastError().text();
        return 0;
    }



    statistic w;
    w.show();

    return a.exec();
}
